﻿using HC.View;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using EMRView;
using EMRView.Extensions.HCAttribute;

namespace EMRView.Extensions.Command.StandardCommand.Edit
{
    [Command(CommandType.编辑, "Zoom", "缩放比例")]
    public class ZoomCommand : BaseCommand
    {
        private readonly static string[] zoomArr = new string[] { "25", "50", "75", "100", "150", "200", "300", "500" };

        public override Icon CommandIcon
        {
            get
            {
                return Properties.HCResource.默认;
            }
        }

        public override object Execute(HCEmrView _view, bool showDefaultUI = false, params object[] para)
        {
            Single vOut = 0;
            if (float.TryParse(para[0] as string, out vOut))
                _view.Zoom = vOut / 100;
            else
                _view.Zoom = 1.0f;
            return null;
        }

        public override void InitControl(object control)
        {

            if (control is ToolStripComboBox)
            {
                var zoomComboBox = control as ToolStripComboBox;
                zoomComboBox.Items.Clear();
                foreach (string size in zoomArr)
                {
                    zoomComboBox.Items.Add(size);
                }
                zoomComboBox.SelectedIndex = zoomComboBox.Items.IndexOf("100");
            }
        }
    }
}
